package com.hsd.aop.proxy;

import org.junit.Test;

import java.lang.reflect.Proxy;

public class Customer {

    @Test
    public void buyClothes() {
        ClothProducer clothProducer = new ClothProducer();
        clothProducer.saleClothes(100);
    }

    @Test
    public void buyClothes002() {
        //被代理对象001
        ClothProducer target = new ClothProducer();
        //被代理对象002
        ShoesProducer shoesProducer = new ShoesProducer();
        //代理类对象
        Businessman businessman = new Businessman(shoesProducer);
        //进行代理操作：
        Sale001 sale = (Sale001) Proxy.newProxyInstance(businessman.getClass().getClassLoader(), shoesProducer.getClass().getInterfaces(), businessman);
        sale.saleShoes(1000.0);
    }

}
